package com.xxxx.servlet;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


/**
 * 重定向
 *   服务端指导，客户端行为
 *   存在两次请求
 *   地址栏会发生改变
 *   request对象不共享
 *
 */
@WebServlet("/s04")
public class Servlet04 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("Servlet04...");

        // 接收参数
        String uname = request.getParameter("uname");
        System.out.println("Servlet04 " + uname);

        // 重定向跳转到s05
        response.sendRedirect("s05");


    }
}
